import Request from "@/sdk/pocky-request/index.js";

const settled = {
    state: {
        settledProgress: {},		//商户审核资料
    },
    mutations: {
		// 更新审核进度
        updateProgress(state, _data) {
            state.settledProgress = _data
        }
    },
	getters:{
		
	},
    actions: {
		// 通过用户ID获取商户审核资料
		getSettledByUid(context,_uid){
			return new Promise(resolve=>{
				Request().request({
					url: '/user/join/process.do',
					method: 'post',
					data: {
						userId: _uid
					}
				}).then(res=>{
					if(res.data.code==1){
						context.commit("updateProgress",res.data.data);
						
						resolve(res)
					}else{
						uni.showToast({
							title: '获取商户资料失败,'+res.data.msg,
							icon: 'none'
						});
					}
				})
			});
		},
		// 新增或修改商户审核
		postSettled(context,_data){
			return new Promise(resolve=>{
				let r = Request();
				r.request({
					url: '/user/join/submit.do',
					method: 'post',
					data: _data
				}).then(res=>{
					if(res.data.code==1){
						uni.showToast({
							title: '资质提交成功',
							icon: 'none'
						});
						resolve(res);
					}else{
						uni.showToast({
							title: '资质提交失败,'+res.data.msg,
							icon: 'none'
						});
					}
				})
			});
			
		}
		
		
		
    }
}

export default settled